Imports Microsoft.VisualBasic
Imports System.Web

Public Class SendEmail

    Public Function SendThisMessage( _
                        ByVal oMessage As JMail.Message, _
                        ByVal sSMTPServer As String, _
                        ByVal sUserID As String, _
                        ByVal sPassword As String)

        Dim sResult As String = ""

        If sUserID > "" Then
            Dim oSMTPServer As New JMail.SendMailObject_GoDaddy(sSMTPServer, sUserID, sPassword)
            sResult = oSMTPServer.SendMessage(oMessage)

        Else
            Dim oSMTPServer As New JMail.SendMailObject_CDO(sSMTPServer)
            sResult = oSMTPServer.SendMessage(oMessage)
        End If

        Return sResult
    End Function

    Public Function SendThisMessage(ByVal oMessage As JMail.Message) As String
        Dim sResult As String = ""

        Dim sMode As String = System.Configuration.ConfigurationManager.AppSettings("JMAIL_MODE")
        Dim sSMTP As String = System.Configuration.ConfigurationManager.AppSettings("JMAIL_SMTP")
        Dim sUID As String = System.Configuration.ConfigurationManager.AppSettings("JMAIL_UID")
        Dim sPWD As String = System.Configuration.ConfigurationManager.AppSettings("JMAIL_PWD")

        If sMode = "ASPMAIL" Then
            Dim oSMTPServer As New JMail.SendMailObject_ASPMAIL(sSMTP)
            sResult = oSMTPServer.SendMessage(oMessage)

        ElseIf sUID > "" Then
            Dim oSMTPServer As New JMail.SendMailObject_GoDaddy(sSMTP, sUID, sPWD)
            sResult = oSMTPServer.SendMessage(oMessage)

        Else
            Dim oSMTPServer As New JMail.SendMailObject_CDO(sSMTP)
            sResult = oSMTPServer.SendMessage(oMessage)
        End If

        Return sResult
    End Function
End Class